<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>
        <a href="/">权限管理</a>
      </el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card v-loading="loading">
      <el-table  :data="rigthsList" border stripe>
        <el-table-column type='index' label='#'></el-table-column>
        <el-table-column label='权限名称' prop="submenu_name"></el-table-column>
        <el-table-column label='路径' prop="path"></el-table-column>
        <el-table-column label='权限等级' prop="level">
          <!-- 作用域插槽 -->
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level === 0">一级</el-tag>
            <el-tag v-if="scope.row.level === 1" type="success">二级</el-tag>
            <el-tag v-if="scope.row.level === 2" type="warning">三级</el-tag>
          </template>
        </el-table-column>

      </el-table>
    </el-card>
  </div>
</template>

<script>
import { getRigthsList } from '../../api/rigths/rigths.js'
export default {
  data () {
    return {
      rigthsList: [],
      queryInfo: {
        query: '',
        // 当前的页数
        pageNum: 0,
        // 当前每页显示多少条
        pageSize: 20
      },
      loading: false
    }
  },
  created () {
    this.getRigths()
  },
  methods: {
    getRigths() {
      this.loading = true
      getRigthsList(this.queryInfo).then(res => {
        this.loading = false
        console.log(res.data)
        if (!res.data.success) return this.$message.error('获取权限列表失败')
        this.rigthsList = res.data.data
      })
    }
  }
}
</script>

<style lang="less" scoped>
</style>
